package com.butioy.study.jersey.service.impl;

import com.butioy.study.jersey.mapper.UserMapper;
import com.butioy.study.jersey.model.User;
import com.butioy.study.jersey.service.IUserService;
import javax.inject.Inject;
import org.jvnet.hk2.annotations.Service;

/**
 * @author yanglq
 * @since 3.0.0
 */
@Service
public class UserServiceImpl implements IUserService {

    @Inject
    private UserMapper userMapper;

    @Override
    public User findById(long userId) {
        return userMapper.selectById(userId);
    }

    @Override
    public User findByAccount(String account) {
        return userMapper.selectByAccount(account);
    }

    @Override
    public void save(User user) {
        user.setCreateTime(System.currentTimeMillis());
        long userId = userMapper.insert(user);
        user.setUserId(userId);
    }
}
